﻿// 1.1.7.19. Write a program, which finds all prime numbers in the range [1, …, 10 000 000].
// Use the sieve of Eratosthenes algorithm (find it in Wikipedia).

using System;

class FindingBigPrimeNumbers
{
    static void Main()
    {
        bool[] notPrime = new bool[10000000];

        for (int i = 2; i < 10000000 / 2; i += 2)
        {
            notPrime[i] = true;
        }
        for (int i = 3; i < 10000000 / 3; i += 3)
        {
            notPrime[i] = true;
        }
        for (int i = 5; i < 10000000 / 5; i += 5)
        {
            notPrime[i] = true;
        }
        for (int i = 7; i < 10000000 / 7; i += 7)
        {
            notPrime[i] = true;
        }

        notPrime[2] = false;
        notPrime[3] = false;
        notPrime[5] = false;
        notPrime[7] = false;
        
        for (int i = 0; i < 100; i++)
        {
            if (notPrime[i] == false)
            {
                Console.WriteLine(i);
            }
        }
    }
}